package main

import (
  "net"
  "log"
  "os"
)

type NetworkClient struct{
  Netting
}

func (this* NetworkClient) initialize(ip string) (chan string, chan string) {
  c, e := net.Dial("tcp", "", ip +":10000")
  if e != nil  {
    log.Stderr("Client: Error: %s", e.String())
    os.Exit(1)
  }
  log.Stdout("Client: Connected", c)
  
  /* create channels to communicate with the clinet */
  in := make(chan string, 100) /* received messages will be forwarded to this channel */
  out := make(chan string, 100) /* messages sent to this channel will be forwarded to the server */
  /* spawn client processes */
  go this.sendLoop(out, c)
  go this.receiveLoop(in, c)
  /* return the channels */
  return in, out
}

